#include "class_factory.h"
#include<iostream>
using namespace std;

Shape::Shape(string id)
{
     this->id = id;
    //  cout<< "正在构建Shape" << endl;
}

string Shape:: getId()
{
    return this->id;
}
void Shape:: operator=(const Shape& other){
    this->id=other.id;

}
Shape::~Shape()
{
    //  cout<< "正在析构Shape" << endl;
}

double Shape::  area()
{
    return 0;
}
Rectangle::Rectangle():Shape("")
{
    cout<< "正在构建Rectangle" << endl;
}

void Rectangle::operator=(const Rectangle& other) {
    this->width = other.width;
    this->height = other.height;
    this->id=other.id;
}


Rectangle::Rectangle(std::string id, double width,double height): Shape(id)
{
    this->width = width;
    this->height = height;
    cout<< "正在构建Rectangle" << endl;
}

Rectangle:: ~Rectangle() 

{
    this->width = 0;
    this->height = 0;
    cout<< "正在析构Rectangle" << endl;
}
double Rectangle::area()
{
    cout<<"调用父类的方法:"<<Shape::area()<<endl;
    return this->width * this->height;
}
